# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=yaegi
pkgver=0.15.1
pkgrel=5
pkgdesc="Elegant Go interpreter"
url="https://github.com/traefik/yaegi"
# 32bit: TestEvalBuiltin test fails
#arch="all !x86 !armhf !armv7"
arch="" # https://gitlab.alpinelinux.org/alpine/aports/-/issues/15253
license="Apache-2.0"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/traefik/yaegi/archive/refs/tags/v$pkgver.tar.gz"
# Required to pass tests.
# Ref: https://github.com/traefik/yaegi/issues/1523#issuecomment-1465730351
builddir="$srcdir/src/github.com/traefik/$pkgname"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

prepare() {
	export GOPATH="$srcdir"

	mkdir -p "$(dirname $builddir)"
	mv "$srcdir/$pkgname-$pkgver" "$builddir"/

	default_prepare
}

build() {
	go build -v -ldflags "-X main.version=v$pkgver" ./cmd/yaegi/
}

check() {
	# extract_test.go:157: cannot find package "math"
	GOFLAGS="${GOFLAGS/-trimpath/}" go test ./...
}

package() {
	install -Dm755 $pkgname -t "$pkgdir"/usr/bin/
}

sha512sums="
e827b370b1f1a7453de02ffa54768372a64730cbde7b09d505e44bdd9d8290de5550e56fcacfdce022a1d4103d26f0cab5104c032d95145036cf09079de20d10  yaegi-0.15.1.tar.gz
"
